﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NGinnBPM.Services
{
    /// <summary>
    /// Connection factory
    /// </summary>
    public interface ITaskDatabaseSessionFactory
    {
        ITaskDatabaseSession OpenSession();
    }

    /// <summary>
    /// Task database connection
    /// </summary>
    public interface ITaskDatabaseSession : IDisposable
    {
        object Connection { get; }
    }

    public class TaskDatabaseSession
    {
        [ThreadStatic]
        private static ITaskDatabaseSession _curSes;

        /// <summary>
        /// Current thread's session
        /// </summary>
        public static ITaskDatabaseSession CurrentSession
        {
            get { return _curSes; }
            set { _curSes = value;}
        }
    }
}
